import re

from src.model import UserPrefs

# Command syntax: @username /hide <count messages>
class HideLatestMessages:
    def process(self, text):
        m = re.search('^.(.*)\s+/hide\s+(\d+)$', text, re.U);
        if m != None:
            username = m.group(1)
            count = int(m.group(2))
            person = UserPrefs.person_by_name(username)
            if person != None:
                person.block_latest_messages(count)
            return True
        return False